package com.leyou.common.exceptions;

import com.leyou.common.enums.ExceptionEnum;
import lombok.Getter;

/**
 * 自定义异常,只是多了状态码
 */
@Getter
public class LyException extends RuntimeException {
    private int status;

    public LyException(int status,String msg){
        super(msg);
        this.status = status;
    }

    public LyException(ExceptionEnum e) {
        super(e.getMessage());
        this.status = e.getStatus();
    }

    public LyException(ExceptionEnum e, Throwable cause) {
        super(e.getMessage(), cause);  //此处e.getMessage()为枚举类中定义的Message,相当于通过有参构造向RuntimeException中传入Message
        this.status = e.getStatus();
    }

}
